package com.junbao.message.infrastructure.core.producer;

import com.junbao.message.domain.model.NotifyMessage;
import com.junbao.message.infrastructure.core.DataProducer;
import com.junbao.message.infrastructure.core.RequestDto;
import com.lmax.disruptor.RingBuffer;

/**
 * 消息发送生产者
 * @author yilin
 *
 */
@SuppressWarnings("all")
public class MessageACKProducer<T> extends DataProducer<T>{

	
	public MessageACKProducer(String producerName, RingBuffer<T> ringBuffer) {
		super(producerName, ringBuffer);
	}

	@Override
	public void sendData(T eventData) {
		long sequence = this.ringBuffer.next();
		try {
			RequestDto<NotifyMessage> data = (RequestDto<NotifyMessage>) eventData;
			RequestDto<NotifyMessage> requestData = (RequestDto<NotifyMessage>) ringBuffer.get(sequence);
			requestData.setbusinessObject(data.getBusinessObject());
		} finally{
			this.ringBuffer.publish(sequence);
		}
	}
	
}